package com.fengwk.cv4j.view.ind;

import com.fengwk.cv4j.compute.Compute;
import com.fengwk.cv4j.factory.ViewFactory;
import com.fengwk.cv4j.utils.Nd4jUtils;
import com.fengwk.cv4j.view.View;
import com.fengwk.cv4j.view.common.MinView;

/**
 * 取矩阵某维度的最小值
 * 
 * @author fengwk
 *
 */
public class INDMinView extends MinView<INDArrayWrap> {

    private static final long serialVersionUID = -1135140140278038306L;

    public INDMinView(Compute<INDArrayWrap> compute, ViewFactory<INDArrayWrap> factory, @SuppressWarnings("unchecked") View<INDArrayWrap>...vs) {
        super(compute, factory, vs);
    }
    
    // 与求取最大值时一致
    @Override
    protected View<INDArrayWrap> gradient0(int idx) {
    	View<INDArrayWrap> d = INDMaxView.gradient0(idx, len(), ts(), f(), (a, ds) -> Nd4jUtils.min(a, ds));
		if (d == null)
			return super.gradient0(idx);
		return d;
	}

}
